package com.water.bs.utils;

import com.water.bs.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Component
public class NumberUtil {
    @Autowired
    private GoodsService goodsService;
    
    //积分获取
    public int pointCount(List<Map<String,Object>> userGoods){
        int rs =0;
        List<Map<String, Object>> goodsList = goodsService.qryGoods();
        for (int i = 0; i < goodsList.size(); i++) {
            for (int j = 0; j < userGoods.size(); j++) {
                if (goodsList.get(i).get("goodname").equals(userGoods.get(j).get("goodsname"))){
//                    rs+=((int)goodsList.get(i).get("goodpoint"))*(userGoods.get(j).get("goodsnum"));
                    int name = (int) goodsList.get(i).get("goodpoint");
                    int num = (int) userGoods.get(j).get("goodsnum");
                    rs +=name*num;
                    break;
                }
            }

        }
        return rs;
    }
}
